import datetime

from PyQt5 import QtWidgets

import UI
import sys

# 主运行函数
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    # if datetime.datetime.today() ==
    # 调用UI.界面的完整路径-开始
    ui = UI.Ui_MainWindow()
    # 调用UI.界面的完整路径-结束
    ui.setupUi(MainWindow)
    e_dt = datetime.datetime(2021, 11, 1, 0, 0, 0)
    s_dt = datetime.datetime.now()
    o_dt = (e_dt - s_dt).days

    if int(o_dt) < 0:
        a = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, "警告", "授权过期：" + str(o_dt), QtWidgets.QMessageBox.Ok)
        a.show()
        if a == QtWidgets.QMessageBox.Yes:
            sys.exit(0)
    elif int(o_dt) < 30:
        b = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, "警告", "授权过期剩余：" + str(o_dt), QtWidgets.QMessageBox.Ok)
        b.show()
        MainWindow.show()
    else:
        MainWindow.show()

    sys.exit(app.exec_())
